load("@fbcode_macros//build_defs:rust_library.bzl", "rust_library")
load("@fbsource//tools/build_defs:glob_defs.bzl", "glob")

oncall("buck2")

rust_library(
    name = "buck2_forkserver",
    srcs = glob(
        ["src/**/*.rs"],
    ),
    mapped_srcs = select({
        "DEFAULT": {},
        "ovr_config//os:linux": {
            "//buck2/app/buck2_miniperf:buck2_miniperf": "src/unix/miniperf.bin",
        },
    }),
    os_deps = [
        (
            "linux",
            [
                "fbsource//third-party/rust:nix",
            ],
        ),
        (
            "macos",
            [
                "fbsource//third-party/rust:nix",
            ],
        ),
        (
            "windows",
            [
                "fbsource//third-party/rust:winapi",
            ],
        ),
    ],
    test_deps = [
        "fbsource//third-party/rust:assert_matches",
        "fbsource//third-party/rust:tempfile",
        "fbsource//third-party/rust:tokio-stream",
    ],
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:async-trait",
        "fbsource//third-party/rust:bincode",
        "fbsource//third-party/rust:bytes",
        "fbsource//third-party/rust:futures",
        "fbsource//third-party/rust:libc",
        "fbsource//third-party/rust:nix",
        "fbsource//third-party/rust:pin-project",
        "fbsource//third-party/rust:rand",
        "fbsource//third-party/rust:take_mut",
        "fbsource//third-party/rust:tokio",
        "fbsource//third-party/rust:tokio-util",
        "fbsource//third-party/rust:tonic",
        "fbsource//third-party/rust:tracing",
        "//buck2/allocative/allocative:allocative",
        "//buck2/app/buck2_common:buck2_common",
        "//buck2/app/buck2_core:buck2_core",
        "//buck2/app/buck2_data:buck2_data",
        "//buck2/app/buck2_forkserver_proto:buck2_forkserver_proto",
        "//buck2/app/buck2_grpc:buck2_grpc",
        "//buck2/app/buck2_miniperf_proto:buck2_miniperf_proto",
        "//buck2/app/buck2_util:buck2_util",
        "//buck2/gazebo/dupe:dupe",
    ],
)
